
import {prefix} from './utils'
import * as sagaEffects  from 'redux-saga/effects';

export default function createRootSaga(models){
   function* rootSaga(){
    for(let model of models){
        model.effects = prefix(model.effects,model.namespace)
        for(let key in model.effects){ //key counter/asyncAdd 监听effects中的动作发生时触发回调
           yield sagaEffects.takeEvery(key,function*(action){
               yield model.effects[key](action,sagaEffects)
           }) 
        }
    }
   }
   return rootSaga
}
